$.ajaxSetup({
  headers: {
    'X-CSRF-TOKEN': '{{ csrf_token() }}'
  }
});
$('#person-paper').on('click', function () {
  $.ajax({
    type: 'GET',
    url: "https://www.fxpixels.site/lv5/public/index.php/paper/userpaper",
    async: false,
    contentType: 'application/json',
    processData: true,
    datatype: "json",
    success: function (data) {
      // console.log(data);
      var article = '';
      var i;
      if (data.length != 0) {
        for (i = 0; i < data.length; i++) {
          // console.log(data[i].cover_img);
          var article_body = data[i].body.substr(0, 50) + '...';
          article +=
            '<li style="margin: 40px 0; list-style:none;">' +
            '<div class="row"><div class="col-md-8 col-xs-7">' +
            '<span>发表于&nbsp;&nbsp;' + data[i].created_at + '</span><div class="title">' +
            '<a style="color: #333333;" href="https://www.fxpixels.site/lv5/public/index.php/article/' + data[i].id + '"><h4 style="font-weight:bold;">' + data[i].title.substr(0, 25)+'..' + '</h4></a></div>' +
            '<div class="body"><p>' + article_body + '</p></div><div>' +
            '<a href="https://www.fxpixels.site/lv5/public/index.php/category?name=' + data[i].category + '"><span style="border: 1px solid #F1907F; padding: 2px 5px; border-radius: 3px; color:#F1907F; ">' + data[i].category + '</span></a>' +
            '&nbsp;&nbsp;&nbsp;阅读&nbsp;(<span>' + data[i].read_total + '</span>)' +
            '&nbsp;&nbsp;&nbsp;回复&nbsp;<span>' + data[i].reply_total + '</span>' +
            '&nbsp;&nbsp;&nbsp;点赞&nbsp;<span>' + data[i].upvote_total + '</span></div></div>' +
            '<div class="col-md-4 col-xs-5"><a href="https://www.fxpixels.site/lv5/public/index.php/article/' + data[i].article_id + '">' +
            '<img class="img-responsive" style="width:200px; height:150px; border-radius:12px;" src="https://www.fxpixels.site/lv5/public/img/cover/' + data[i].cover_img + '"' + "alt=''>" +
            '</a></div></div></li><hr style="margin: 5px 0; width:100%; height:5px;">';
        }
        $('#person-articles').html(article);
      } else {
        $('#person-articles').html('<span>你没有发表过日报通过审核…</span>');
      }
    },
    error: function (XMLHttpRequest, textStatus, errorThrown) {
      console.log('XMLHttpRequest.status=' + XMLHttpRequest.status);
      console.log('XMLHttpRequest.readyState=' + XMLHttpRequest.readyState);
      console.log('atextStatus=' + textStatus);
    }
  });
})